package com.example.jussi.smsmanagerdemo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

/**
 * 利用 SmsManager 来发送短信
 */
public class MainActivity extends AppCompatActivity {
    EditText number, content;
    Button button;
    SmsManager manager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        manager = SmsManager.getDefault();
        number = (EditText) findViewById(R.id.editText);
        content = (EditText) findViewById(R.id.editText2);
        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                manager.sendTextMessage(number.getText().toString(), null, content.getText().toString(), null, null);
            }
        });
    }
}
